package Task2;

import java.util.ArrayList;

public class EmailAdder implements Runnable {
	private Queue queue;
	private ArrayList<Email> emailList;
	private boolean stop;

	public EmailAdder(Queue queue, ArrayList<Email> arList) {
		this.queue = queue;
		this.emailList = arList;
	}

	public synchronized void stopWork() {
		stop = true;
	}

	public void run() {
		while (!stop) {
			queue.addEmail(emailList.get(0));
			emailList.remove(0);
		}
	}
}